"""
这里面封装的是yaml的读写删
yaml文件的规则
"""
import yaml
import os

from common.path import get_data_path,get_extral_path
dti={"ssss":"ssss"}#可以直接把变量放入


def read_data_yaml():
    """
    读取数据驱动
    :return:
    """
    with open(get_data_path(),encoding='utf-8')as f:#获取路径 默认是读 这时通过读取数据驱动参数
        data=yaml.load(f,Loader=yaml.FullLoader)#读取文件流
        return data #返回数据

def read_extract_yaml():
    """
    读取关联yaml
    :return:
    """
    with open(get_extral_path(),encoding='utf-8')as f:#获取路径 默认是读 这时通过读取数据驱动参数
        data=yaml.load(f,Loader=yaml.FullLoader)#读取文件流
        return data #返回数据
def wirte_extract_yaml(data):#写入yaml
     with open(get_extral_path(),mode='w',encoding='utf-8') as f:
         yaml.dump(data=data, stream=f, allow_unicode=True)
def clear_yaml():
            with open(get_extral_path(), mode='w', encoding='utf-8') as f:
              f.truncate()
if __name__=='__main__':
    print(wirte_extract_yaml(dti))



    # test-yaml.py内容
    # import os
    # import yaml
    #
    #
    # class Yamlutil:
    #     # 读取yaml文件
    #     def read_yaml(self):
    #         with open(os.getcwd() + "/extract.yml", mode='r', encoding='utf-8') as f:
    #             value = yaml.load(stream=f, Loader=yaml.FullLoader)
    #             return value;
    #
    #     # 写入yaml文件
    #     def write_yaml(self):
    #         with open(os.getcwd() + "/extract.yml", mode='w', encoding='utf-8') as f:
    #             yaml.dump(data=data, stream=f, allow_unicode=True)
    #
    #     # 清除文件
    #     def clear_yaml(self):
    #         with open(os.getcwd() + "/extract.yaml", mode='w', encoding='utf-8') as f:
    #             f.truncate()
